home *** CD-ROM | disk | FTP | other *** search
-
-
- func()
- {
- int msqid, msglen;
- char string[80];
- struct mssg {
- long mtype;
- char mtext[BUFSIZ];
- } msgbuf;
-
- /* Prompt user for a message to send */
- printf("Enter message: ");
- gets(msgbuf.mtext);
-
- /* Prompt user for a message type */
- printf("Enter message type: ");
- gets(string);
- sscanf(string,"%ld",&(msgbuf.mtype));
-
- /* Set the message length */
- msglen=strlen(msgbuf.mtext);
-
- /* Send the message. The kernel will put
- * the process to sleep if the message queue
- * is full.
- */
- if (msgsnd(msqid, &msgbuf, msglen, 0) == -1) {
- /* The perror(3C) function prints the
- * text of the error number contained
- * in the external integer errno.
- */
- perror("msgsnd() failed: ");
- exit(1);
- }
- }
-
-